<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>短信接入管理</title>
<@fm.header />
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 500px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	<form id="ff" method="post">
		<input type="hidden" name="id"   value=${smsconfig.id}></input>
		<input type="hidden" name="isUseful"   value=${smsconfig.isUseful}></input>
	    <table>
	        <tr>
	            <td><label for="name">名称:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="name" data-options="required:true,validType:'length[1,255]'" value=${smsconfig.name}></input></td>
	        </tr>
	        <tr>    
	            <td><label for="code">编号:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="code" data-options="required:true,validType:'length[1,255]'" value=${smsconfig.code}></input>  </td>
	        </tr>
	        
	         <tr>
	            <td><label for="taskNum">数量:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="taskNum" value=${smsconfig.taskNum}></input></td>
	        </tr>
	        
	        <tr>
	            <td><label for="sendSms">发送短信内容:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="sendSms" value=${smsconfig.sendSms}></input></td>
	        </tr>
	        
	         <tr>
	            <td><label for="carrier">运营商</label></td>
	            <td>
	            	<input type="checkbox" name="carrierCheck" value="2" >移动</input>
	            	<input type="checkbox" name="carrierCheck" value="1" >联通</input>
	            	<input type="checkbox" name="carrierCheck" value="0" >电信</input>
	            	<input id="carrier" type="hidden" name="carrier" value=${smsconfig.carrier} >
	            </td>
	            
	        </tr>
	        
	        <tr>    
	            <td><label for="channelName">限制渠道:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="channelName" value=${smsconfig.channelName}></input>  </td>
	        </tr>
	        
	         <tr>    
	            <td><label for="channelName">过滤渠道:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="filterChannel" value=${smsconfig.filterChannel}></input>  </td>
	        </tr>
	        
	          <tr>
	            <td><label for="sendPhoneNum">发送短信号码:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="sendPhoneNum" value=${smsconfig.sendPhoneNum} ></input></td>
	        </tr>
	        
	        <tr>
	            <td><label for="taskType">任务类型:</label></td>
	            <td> 
		            <select class="easyui-combobox" name="taskType" panelHeight="auto" style="width:155px"  value=${smsconfig.taskType} data-options="required:true">
		                <option value="1"<#if smsconfig.taskType?exists && smsconfig.taskType == 1>selected</#if>>发送短信接收验证码</option>
	                	<option value="0"<#if smsconfig.taskType?exists && smsconfig.taskType == 0>selected</#if>>接收验证码</option>
                        <option value="2"<#if smsconfig.taskType?exists && smsconfig.taskType == 2>selected</#if>>发送短信</option>
		            </select>
	    	 </td>
	        </tr>
	        
	        
	         <tr>
	            <td><label for="callbackUrl">回调地址:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="callbackUrl"  style="width:400px" data-options="validType:'url'" value=${smsconfig.callbackUrl}></input></td>
	        </tr>
	        
	        <tr>
	           <td><label for="smsId">拦截策略:</label></td>
	            <td colspan="3">
	            	<input id="smsId" class="easyui-combogrid" style="width: 400px;height: 28px;" name="smsId" data-options="
						panelWidth: 400,
						panelHeight: '150',
						multiple:true,
						multiline:true,
						url:'/interceptInfo/content?defaultValues=${smsconfig.smsId}',
						method:'get',
						idField: 'id',
            			textField: 'msgContent',
						columns: [[
							{field:'id',title:'编号',width:30},
			                {field:'msgContent',title:'拦截策略',width:150},
			                {field:'regexContent',title:'正则表达式验证码',width:120}
			            ]],
            			fitColumns: true 
						"/>
	            </td>
	        </tr>
	    </table>
	</form>
	</div>
	<div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="edit()">提交</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
	</div>
	
</div>
<script>

	$(function(){
		$('#smsId').combogrid('setValues',[${smsconfig.smsId}]);
		
		var val = $("#carrier").val().split(",");
	    var groupCheckbox=$("input[name='carrierCheck']");
	    for(i=0;i<groupCheckbox.length;i++){
	    	for(j=0;j<val.length;j++){
		         if(groupCheckbox[i].value == val[j]){
		             groupCheckbox[i].checked = true;
		          }
	        }
	    }
		
	});
	
	
	function edit() {
	
	$('#ff').form(
	    'submit',
	    {
			url : '/smsconfig/update',
			onSubmit : function() {
			
				var f_str = '';
				var groupCheckbox=$("input[name='carrierCheck']");
			    for(i=0;i<groupCheckbox.length;i++){
			        if(groupCheckbox[i].checked){
			            var val =groupCheckbox[i].value;
						f_str +=val+",";
			        }
			    }
			    $('#carrier').val(f_str)
				return $(this).form('enableValidation').form('validate');
			},
			success : function(data) {
				showProcess(false);
				var data = eval('(' + data + ')');
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				}else if(data.return_code == '10'){
					$.messager.alert(market.content.title, data.return_msg);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		}); 
}
	
</script>
</body>
 
</html>